//
//  MYTabViewController.m
//  feicuiwan
//
//  Created by ZhengYing on 2017/7/5.
//  Copyright © 2017年 zy. All rights reserved.
//

#import "MYTabViewController.h"
#import "HousePicController.h"
#import "QWViewController.h"
#import "SandBoxViewController.h"
#import "JSQViewController.h"
#define mHeight 200
@interface MYTabViewController ()
{
    UIView *contentView;
}
@end

@implementation MYTabViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    contentView = [[UIView alloc]initWithFrame:CGRectMake(0, 768-mHeight, 1024, mHeight)];
    [self.view addSubview:contentView];
    contentView.backgroundColor = [UIColor clearColor];
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 1024, mHeight)];
    imageView.image = [UIImage imageNamed:@"tabbar_bottom"];
    [contentView addSubview:imageView];
    
    int x = 57;
    int padding = 39;
    NSArray *arr= @[@"58",@"33",@"25",@"45",@"33",@"45",@"58"];
    for (int i=0;i<7;i++) {
        
        UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(x, [arr[i] intValue], 96, 130)];
        [btn setImage:[UIImage imageNamed:[NSString stringWithFormat:@"btn_home_%d",i+1]] forState:UIControlStateNormal];
        btn.tag= i;
        [btn addTarget:self action:@selector(searchItem:) forControlEvents:UIControlEventTouchUpInside];
        [contentView addSubview:btn];
        x +=padding+96;
    }
    // Do any additional setup after loading the view.
}

-(void)showTabbar{
    contentView.frame =CGRectMake(0, 768-mHeight, 1024, mHeight);
    self.tabBar.hidden=YES;
    self.hidesBottomBarWhenPushed=YES;

}

-(void)hiddenTibbar{
    self.tabBar.hidden=YES;
    self.hidesBottomBarWhenPushed=YES;

    contentView.frame =CGRectMake(0, 768, 1024, mHeight);

}

-(void)searchItem:(UIButton *)btn{
    
    if (btn.tag==0) {
        self.selectedIndex = 0;

        HousePicController *house = [[HousePicController alloc]initWithPath:@"skin/xmgk/" type:@"jpg"];
        [self.nav pushViewController:house animated:YES];
        [self hiddenTibbar];
    }else if(btn.tag==1){
        self.selectedIndex = 0;

        QWViewController *qw = [self.storyboard instantiateViewControllerWithIdentifier:@"QWViewController"];
        [self.nav pushViewController:qw animated:YES];
        [self hiddenTibbar];

    }else if(btn.tag==2){
        self.selectedIndex = 0;

        SandBoxViewController *sandBox = [self.storyboard instantiateViewControllerWithIdentifier:@"SandBoxViewController"];
        [self.nav pushViewController:sandBox animated:YES];
        [self hiddenTibbar];


    }else if(btn.tag==6){
        self.selectedIndex = 0;
        
        JSQViewController *house = [[JSQViewController alloc]init];
        [self.nav pushViewController:house animated:YES];
        [self hiddenTibbar];
        
        
    }else{
        self.selectedIndex = btn.tag;

    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
